Sensor Fusion for Kinetis MCUs (ISSDK/KSDK version)
status.c File Reference
+ Include dependency graph for status.c:

Go to the source code of this file.

Macros

#define N   0x00
 
#define R   0x04
 
#define G   0x02
 
#define B   0x01
 

Functions

void ssSetLeds (int8_t RGB)
 
void ssSetStatusNow (StatusSubsystem *pStatus, fusion_status_t status)
 
void ssTest (StatusSubsystem *pStatus)
 
void ssQueueStatus (StatusSubsystem *pStatus, fusion_status_t status)
 
void ssUpdateStatus (StatusSubsystem *pStatus)
 
void ssSetStatus (StatusSubsystem *pStatus, fusion_status_t status)
 
void initializeStatusSubsystem (StatusSubsystem *pStatus)
 

Detailed Description

Applications may change how they choose to display status information. The default implementation here uses LEDs on NXP Freedom boards. You may swap out implementations as long as the "Required" methods and states are retained.

Definition in file status.c.

Macro Definition Documentation

#define B   0x01

Definition at line 50 of file status.c.

Referenced by ssSetLeds().

#define G   0x02

Definition at line 49 of file status.c.

Referenced by ssSetLeds(), and ssSetStatusNow().

#define N   0x00

Definition at line 47 of file status.c.

Referenced by ssSetStatusNow().

#define R   0x04

Definition at line 48 of file status.c.

Referenced by ssSetLeds(), and ssSetStatusNow().

Function Documentation

void initializeStatusSubsystem ( StatusSubsystem pStatus)

initializeStatusSubsystem() should be called once at startup to initialize the data structure and to put hardware into the proper state for communicating status.

Parameters
pStatuspointer to the status subsystem

Definition at line 185 of file status.c.

Referenced by main().

186 {
187  pStatus->set = ssSetStatus;
188  pStatus->queue = ssQueueStatus;
189  pStatus->update = ssUpdateStatus;
190  pStatus->test = ssTest;
191  pStatus->previous = OFF;
192  pStatus->set(pStatus, OFF);
193  pStatus->queue(pStatus, OFF);
194  pStatus->toggle = false;
195 
196  /* Un-gate the port clocks */
197  CLOCK_EnableClock(RED_LED.clockName);
198  CLOCK_EnableClock(GREEN_LED.clockName);
199  //CLOCK_EnableClock(BLUE_LED.clockName);
200 
201  /* Led pin mux Configuration */
202  PORT_SetPinMux(BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN,
203  kPORT_MuxAsGpio);
204  PORT_SetPinMux(BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN,
205  kPORT_MuxAsGpio);
206  //PORT_SetPinMux(BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN,
207  // kPORT_MuxAsGpio);
208 
209  /* set initial values */
210  LED_RED_INIT(LOGIC_LED_OFF);
211  LED_GREEN_INIT(LOGIC_LED_OFF);
212  //LED_BLUE_INIT(LOGIC_LED_OFF);
213 }
ssUpdateStatus_t * test
unit test which simply increments to next state
Definition: status.h:53
void ssTest(StatusSubsystem *pStatus)
Definition: status.c:125
fusion_status_t previous
Previous status state - fusion_status_t is defined in sensor_fusion.h.
Definition: status.h:46
These are the state definitions for the status subsystem.
void ssQueueStatus(StatusSubsystem *pStatus, fusion_status_t status)
Definition: status.c:164
uint8_t toggle
This implementation can change LED color and have either solid/toggle.
Definition: status.h:55
void ssUpdateStatus(StatusSubsystem *pStatus)
Definition: status.c:170
ssUpdateStatus_t * update
make pending status active/visible
Definition: status.h:52
void ssSetStatus(StatusSubsystem *pStatus, fusion_status_t status)
Definition: status.c:177
ssSetStatus_t * set
change status immediately - no delay
Definition: status.h:50
ssSetStatus_t * queue
queue status change for next regular interval
Definition: status.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ssQueueStatus ( StatusSubsystem pStatus,
fusion_status_t  status 
)

Definition at line 164 of file status.c.

Referenced by initializeStatusSubsystem().

165 {
166  pStatus->next = status;
167 }
fusion_status_t next
Pending status change.
Definition: status.h:48

+ Here is the caller graph for this function:

void ssSetLeds ( int8_t  RGB)

Definition at line 53 of file status.c.

Referenced by ssSetStatusNow().

54 {
55  if (RGB & R)
56  LED_RED_ON();
57  else
58  LED_RED_OFF();
59  if (RGB & G)
60  LED_GREEN_ON();
61  else
62  LED_GREEN_OFF();
63  if (RGB & B)
64  LED_BLUE_ON();
65  else
66  LED_BLUE_OFF();
67 }
#define G
Definition: status.c:49
#define B
Definition: status.c:50
#define R
Definition: status.c:48

+ Here is the caller graph for this function:

void ssSetStatus ( StatusSubsystem pStatus,
fusion_status_t  status 
)

Definition at line 177 of file status.c.

Referenced by initializeStatusSubsystem().

178 {
179  pStatus->next = status;
180  ssUpdateStatus(pStatus);
181 }
void ssUpdateStatus(StatusSubsystem *pStatus)
Definition: status.c:170
fusion_status_t next
Pending status change.
Definition: status.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ssSetStatusNow ( StatusSubsystem pStatus,
fusion_status_t  status 
)

Definition at line 70 of file status.c.

Referenced by ssTest(), and ssUpdateStatus().

71 {
72  pStatus->status = status;
73  pStatus->next = status;
74 
75  uint8_t blink = false;
76  uint8_t RGB = N;
77 
78  // This is where we actually change the visual indicator
79  // We are not using the blue LED because it is not available on some
80  // board combinations.
81  switch (status)
82  {
83  case INITIALIZING: // solid GREEN
84  RGB = G;
85  break;
86  case NORMAL: // blinking GREEN
87  RGB = G;
88  blink = true;
89  break;
90  case LOWPOWER: // blinking YELLOW
91  RGB = R|G;
92  blink = true;
93  break;
94  case SOFT_FAULT: // solid RED (usually momentary)
95  case HARD_FAULT: // solid RED
96  RGB = R;
97  break;
98  default: // default = off;
99  RGB = N;
100  }
101 
102  if ((!blink) | (status != pStatus->previous))
103  {
104  ssSetLeds(RGB);
105  pStatus->toggle = true;
106  }
107  else
108  {
109  if (pStatus->toggle)
110  {
111  ssSetLeds(N);
112  }
113  else
114  {
115  ssSetLeds(RGB);
116  }
117 
118  pStatus->toggle = !pStatus->toggle;
119  }
120  while (status == HARD_FAULT) ; // Never return on hard fault
121  // while (status == SOFT_FAULT) ; // DEBUG ONLY Never return on soft fault
122 }
Initializing sensors and algorithms.
fusion_status_t status
Current status.
Definition: status.h:47
#define G
Definition: status.c:49
fusion_status_t previous
Previous status state - fusion_status_t is defined in sensor_fusion.h.
Definition: status.h:46
uint8_t toggle
This implementation can change LED color and have either solid/toggle.
Definition: status.h:55
Recoverable FAULT = something went wrong, but we can keep going.
void ssSetLeds(int8_t RGB)
Definition: status.c:53
#define R
Definition: status.c:48
Running in reduced power mode.
#define N
Definition: status.c:47
Non-recoverable FAULT = something went very wrong.
Operation is Nominal.
fusion_status_t next
Pending status change.
Definition: status.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ssTest ( StatusSubsystem pStatus)

Definition at line 125 of file status.c.

Referenced by initializeStatusSubsystem().

126 {
127  switch (pStatus->status)
128  {
129  case OFF:
130  ssSetStatusNow(pStatus, INITIALIZING);
131  break;
132  case INITIALIZING:
133  ssSetStatusNow(pStatus, LOWPOWER);
134  break;
135  case LOWPOWER:
136  ssSetStatusNow(pStatus, NORMAL);
137  break;
138  case NORMAL:
140  break;
141  case RECEIVING_WIRED:
143  break;
144  case RECEIVING_WIRELESS:
145  ssSetStatusNow(pStatus, SOFT_FAULT);
146  break;
147  case SOFT_FAULT:
148  ssSetStatusNow(pStatus, HARD_FAULT);
149  break;
150  case HARD_FAULT:
151  ssSetStatusNow(pStatus, OFF);
152  break;
153  }
154 }
Initializing sensors and algorithms.
fusion_status_t status
Current status.
Definition: status.h:47
void ssSetStatusNow(StatusSubsystem *pStatus, fusion_status_t status)
Definition: status.c:70
Receiving commands over wireless interface (momentary)
These are the state definitions for the status subsystem.
Recoverable FAULT = something went wrong, but we can keep going.
Receiving commands over wired interface (momentary)
Running in reduced power mode.
Non-recoverable FAULT = something went very wrong.
Operation is Nominal.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ssUpdateStatus ( StatusSubsystem pStatus)

Definition at line 170 of file status.c.

Referenced by initializeStatusSubsystem(), and ssSetStatus().

171 {
172  pStatus->previous = pStatus->status;
173  ssSetStatusNow(pStatus, pStatus->next);
174 }
fusion_status_t status
Current status.
Definition: status.h:47
void ssSetStatusNow(StatusSubsystem *pStatus, fusion_status_t status)
Definition: status.c:70
fusion_status_t previous
Previous status state - fusion_status_t is defined in sensor_fusion.h.
Definition: status.h:46
fusion_status_t next
Pending status change.
Definition: status.h:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function: